package com.java.mall_imooc.common.enums;

import com.lly835.bestpay.enums.BestPayTypeEnum;
import lombok.Getter;

/**
 * 支付平台枚举
 * @author jiangli
 * @since 2020-03-15 0:02

 */
@Getter
public enum PayPlatformEnum {
    ALIPAY(1),
    WX(2),
    ;

    Integer code;

    PayPlatformEnum(Integer code) {
        this.code = code;
    }

    public static Integer getPayPlatform(BestPayTypeEnum bestPayTypeEnum) {
        for (PayPlatformEnum payPlatform : PayPlatformEnum.values()) {
            if (payPlatform.name().equals(bestPayTypeEnum.getPlatform().name())) {
                return payPlatform.getCode();
            }
        }

        throw new RuntimeException("未知的支付平台!");
    }
}
